import com.alibaba.fastjson.JSON;
import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.ArrayListHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.junit.Test;

import java.sql.SQLException;
import java.util.List;

public class Test01 {

    @Test
    public void test01() throws SQLException {
        ComboPooledDataSource dataSource = new ComboPooledDataSource();
        System.out.println(dataSource);
        QueryRunner queryRunner = new QueryRunner(dataSource);
        String name="王";
        String sql = "select * from user where name like '%"+name+"%'";
        List<User> query = queryRunner.query(sql, new BeanListHandler<User>(User.class));
        System.out.println(query.size());
        String use = JSON.toJSONString(query);
        System.out.println(use);
    }

}
